vbscript

推荐列表 站点导航

当前位置:首页 > 脚本编程 > vbscript >

vs中.h文件与.cpp文件之间的切换

来源:网络整理  作者:网友投稿  发布时间:2020-12-27 20:58
我最近写了很多C++程序,头文件与源文件之间的切换实在是件痛苦的事。在vc6 0中有一个宏可以实现这个切换,但是我...

我最近写了很多C++程序,头文件与源文件之间的切换实在是件痛苦的事。在vc6.0中有一个宏可以实现这个切换,但是我发现这个宏在vs2008中不好用。像其他出色的程序员一样,我决定自己写一个宏来实现这个功能。

如果你之前没有写过这个宏,那么请参考以下步骤:
1.在vs中选择Tools | Macros | Macros IDE,打开宏窗口;
2.右键点击左侧目录的MyMacros,选择Add | Add Module新建一个文件,将其重命名为CppUtilities,此时这个文件会在编辑器中打开;
3.在public Module CppUtilities和End Module两行之间添加如下代码:

Public Sub SwitchBetweenSourceAndHeader() Dim currentDocument As String Dim targetDocument As String currentDocument = ActiveDocument.FullName If currentDocument.EndsWith(“.cpp”, StringComparison.InvariantCultureIgnoreCase) Then targetDocument = Left(currentDocument, Len(currentDocument) - 3) + “h” OpenDocument(targetDocument) ElseIf currentDocument.EndsWith(“.h”, StringComparison.InvariantCultureIgnoreCase) Then targetDocument = Left(currentDocument, Len(currentDocument) - 1) + “cpp” OpenDocument(targetDocument) End If End Sub Private Sub OpenDocument(ByRef documentName As String) Dim document As EnvDTE.Document Dim activatedTarget As Boolean activatedTarget = False For Each document In Application.Documents If document.FullName = documentName And document.Windows.Count > 0 Then document.Activate() activatedTarget = True Exit For End If Next If Not activatedTarget Then Application.Documents.Open(documentName, “Text”) End If End Sub

4.ctrl+S保存,点击Tools | Options,在弹出的窗口中选择Environment | Keyboard,
在Show commands containing下面的文本框中输入CppUtilities;
5.点击Press shortcut keys下面文本框,按你想设置的快捷键(博主用的是Alt+F8);
6.点击OK,回到工程中测试一下吧!

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/vbscript/9830.shtml

相关文章
最新文章
利用DataGridView举办增删改 利用DataGridView举办增删改

时间:2021-01-13

VB.NET简朴UDP联机措施 VB.NET简朴UDP联机措施

时间:2021-01-13

 obj.ScaleMode)/s phgt = obj.Sc obj.ScaleMode)/s phgt = obj.Sc

时间:2021-01-13

机房收费系统之报表(二 机房收费系统之报表(二

时间:2020-12-28

VB.NET TextBox设定第几行选取 VB.NET TextBox设定第几行选取

时间:2020-12-28

VB.NET 串口异步访问 VB.NET 串口异步访问

时间:2020-12-27

限制字符串输入 正则表达 限制字符串输入 正则表达

时间:2020-12-27

ListView的基本操作(新增、 ListView的基本操作(新增、

时间:2020-12-27

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

vs中.h文件与.cpp文件之间的切换

2020-12-27 编辑:网友投稿

我最近写了很多C++程序,头文件与源文件之间的切换实在是件痛苦的事。在vc6.0中有一个宏可以实现这个切换,但是我发现这个宏在vs2008中不好用。像其他出色的程序员一样,我决定自己写一个宏来实现这个功能。

如果你之前没有写过这个宏,那么请参考以下步骤:
1.在vs中选择Tools | Macros | Macros IDE,打开宏窗口;
2.右键点击左侧目录的MyMacros,选择Add | Add Module新建一个文件,将其重命名为CppUtilities,此时这个文件会在编辑器中打开;
3.在public Module CppUtilities和End Module两行之间添加如下代码:

Public Sub SwitchBetweenSourceAndHeader() Dim currentDocument As String Dim targetDocument As String currentDocument = ActiveDocument.FullName If currentDocument.EndsWith(“.cpp”, StringComparison.InvariantCultureIgnoreCase) Then targetDocument = Left(currentDocument, Len(currentDocument) - 3) + “h” OpenDocument(targetDocument) ElseIf currentDocument.EndsWith(“.h”, StringComparison.InvariantCultureIgnoreCase) Then targetDocument = Left(currentDocument, Len(currentDocument) - 1) + “cpp” OpenDocument(targetDocument) End If End Sub Private Sub OpenDocument(ByRef documentName As String) Dim document As EnvDTE.Document Dim activatedTarget As Boolean activatedTarget = False For Each document In Application.Documents If document.FullName = documentName And document.Windows.Count > 0 Then document.Activate() activatedTarget = True Exit For End If Next If Not activatedTarget Then Application.Documents.Open(documentName, “Text”) End If End Sub

4.ctrl+S保存,点击Tools | Options,在弹出的窗口中选择Environment | Keyboard,
在Show commands containing下面的文本框中输入CppUtilities;
5.点击Press shortcut keys下面文本框,按你想设置的快捷键(博主用的是Alt+F8);
6.点击OK,回到工程中测试一下吧!

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/vbscript/9830.shtml

相关文章

风云图片

推荐阅读

返回vbscript频道首页